package com.ruiysoft.crm.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruiysoft.crm.model.dto.BizBookingClientDTO;
import com.ruiysoft.crm.model.entity.BizBookingClient;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @author fanyl
 */
public interface BizBookingClientMapper extends BaseMapper<BizBookingClient> {

    @Update("update biz_booking_client set read_status='1' where id=#{id}")
    int changeStatusById(String id);

    List<BizBookingClientDTO> queryBookingInfo(IPage page, @Param("params") Map<String, Object> params);

    List<BizBookingClientDTO> queryBookingInfo(@Param("params") Map<String, Object> params);
    List<BizBookingClientDTO> queryUnReadBooking(@Param("params") Map<String, Object> params);

    @Select("select count(id) from biz_booking_client booking where IFNULL(booking.read_Status, 0) = 0 and booking.booking_time BETWEEN #{startDate } and #{endDate } and booking.user_id =#{id }")
    int getBookingCountByDate(@Param("startDate")LocalDateTime startDate, @Param("endDate")LocalDateTime endDate,@Param("id") String id);
    @Update("update biz_booking_client set read_status='1' where clientId=#{userId}")
    int changeStatusByClientId(Integer userId);
}
